home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _E4703FAECD974DC1A60F072DCEF57AB3 < prev    next >
Encoding:
Text File  |  2002-04-06  |  3.3 KB  |  179 lines

  1. // Copyright (C) 2001-2002 Raven Software.
  2. //
  3.  
  4. #include "gt_local.h"
  5.  
  6. void    GT_Init        ( void );
  7. void    GT_RunFrame    ( int time );
  8. int        GT_Event    ( int cmd, int time, int arg0, int arg1, int arg2, int arg3, int arg4 );
  9.  
  10. gametypeLocals_t    gametype;
  11.  
  12. typedef struct 
  13. {
  14.     vmCvar_t    *vmCvar;
  15.     char        *cvarName;
  16.     char        *defaultString;
  17.     int            cvarFlags;
  18.     float        mMinValue, mMaxValue;
  19.     int            modificationCount;  // for tracking changes
  20.     qboolean    trackChange;        // track this variable, and announce if changed
  21.     qboolean    teamShader;            // track and if changed, update shader state
  22.  
  23. } cvarTable_t;
  24.  
  25. static cvarTable_t gametypeCvarTable[] = 
  26. {
  27.     { NULL, NULL, NULL, 0, 0.0f, 0.0f, 0, qfalse },
  28. };
  29.  
  30. /*
  31. ================
  32. vmMain
  33.  
  34. This is the only way control passes into the module.
  35. This must be the very first function compiled into the .q3vm file
  36. ================
  37. */
  38. int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) 
  39. {
  40.     switch ( command ) 
  41.     {
  42.         case GAMETYPE_INIT:
  43.             GT_Init ( );
  44.             return 0;
  45.  
  46.         case GAMETYPE_START:
  47.             return 0;
  48.  
  49.         case GAMETYPE_RUN_FRAME:
  50.             GT_RunFrame ( arg0 );
  51.             return 0;
  52.  
  53.         case GAMETYPE_EVENT:
  54.             return GT_Event ( arg0, arg1, arg2, arg3, arg4, arg5, arg6 );
  55.     }
  56.  
  57.     return -1;
  58. }
  59.  
  60. /*
  61. =================
  62. GT_RegisterCvars
  63. =================
  64. */
  65. void GT_RegisterCvars( void ) 
  66. {
  67.     cvarTable_t    *cv;
  68.  
  69.     for ( cv = gametypeCvarTable ; cv->cvarName != NULL; cv++ ) 
  70.     {
  71.         trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags, cv->mMinValue, cv->mMaxValue );
  72.         
  73.         if ( cv->vmCvar )
  74.         {
  75.             cv->modificationCount = cv->vmCvar->modificationCount;
  76.         }
  77.     }
  78. }
  79.  
  80. /*
  81. =================
  82. GT_UpdateCvars
  83. =================
  84. */
  85. void GT_UpdateCvars( void ) 
  86. {
  87.     cvarTable_t    *cv;
  88.  
  89.     for ( cv = gametypeCvarTable ; cv->cvarName != NULL; cv++ ) 
  90.     {
  91.         if ( cv->vmCvar ) 
  92.         {
  93.             trap_Cvar_Update( cv->vmCvar );
  94.  
  95.             if ( cv->modificationCount != cv->vmCvar->modificationCount ) 
  96.             {
  97.                 cv->modificationCount = cv->vmCvar->modificationCount;
  98.             }
  99.         }
  100.     }
  101. }
  102.  
  103. /*
  104. ================
  105. GT_Init
  106.  
  107. initializes the gametype by spawning the gametype items and 
  108. preparing them
  109. ================
  110. */
  111. void GT_Init ( void )
  112. {
  113.     memset ( &gametype, 0, sizeof(gametype) );
  114.  
  115.     // Register all cvars for this gametype
  116.     GT_RegisterCvars ( );
  117. }
  118.  
  119. /*
  120. ================
  121. GT_RunFrame
  122.  
  123. Runs all thinking code for gametype
  124. ================
  125. */
  126. void GT_RunFrame ( int time )
  127. {
  128.     gametype.time = time;
  129.  
  130.     GT_UpdateCvars ( );
  131. }
  132.  
  133. /*
  134. ================
  135. GT_Event
  136.  
  137. Handles all events sent to the gametype
  138. ================
  139. */
  140. int GT_Event ( int cmd, int time, int arg0, int arg1, int arg2, int arg3, int arg4 )
  141. {
  142.     switch ( cmd )
  143.     {
  144.         default:
  145.             break;
  146.     }
  147.  
  148.     return 0;
  149. }
  150.  
  151. #ifndef GAMETYPE_HARD_LINKED
  152. // this is only here so the functions in q_shared.c and bg_*.c can link (FIXME)
  153.  
  154. void QDECL Com_Error( int level, const char *msg, ... ) 
  155. {
  156.     va_list        argptr;
  157.     char        text[1024];
  158.  
  159.     va_start (argptr, msg);
  160.     vsprintf (text, msg, argptr);
  161.     va_end (argptr);
  162.  
  163.     trap_Error( text );
  164. }
  165.  
  166. void QDECL Com_Printf( const char *msg, ... ) 
  167. {
  168.     va_list        argptr;
  169.     char        text[1024];
  170.  
  171.     va_start (argptr, msg);
  172.     vsprintf (text, msg, argptr);
  173.     va_end (argptr);
  174.  
  175.     trap_Print( text );
  176. }
  177.  
  178. #endif
  179.